#include <cstdio>
#include <algorithm>

using namespace std;

#define forn( i,n ) for ( int i=0; i<(int)(n); i++ )

int n;
double a[100010], b[100010];
int p[100010];
char s[9870];

bool cmp( int i, int j ) {
  return b[i] < b[j];
}

void readFile( char* fname, double* a ) {
  freopen( fname, "r", stdin );
  gets( s );
  n = 0;
  while ( gets( s ) )
    sscanf( s, "%*d,%lf", &a[n++] );

  fclose( stdin );
}

int main( int argc, char* argv[] ) {
  if ( argc != 3 ) {
    fprintf( stderr, "Usage: getGini <correct-file> <predicted-file>\n" );
    return 0;
  }

  readFile( argv[1], a );
  readFile( argv[2], b );

  forn( i, n ) p[i] = i;
  sort( p, p+n, cmp );

  double stop = 0, sbot = 0;
  forn( i, n ) {
    stop += (i+1) * a[ p[i] ];
    sbot += a[ p[i] ];
  }

  sbot *= n;
  stop *= 2;

  printf( "Gini = %.7f\n", stop  / sbot - ( n + 1.0 ) / n );

  return 0;
}